Quantcast
Channel: Aspose.Pdf Product Family
Viewing all 1038 articles
Browse latest View live

How to hide measurement annotations

$
0
0
Hi Guys 
I need to hide any ruler or measurement annotation that may be part of a pdf document.

Im using the following code however there doesn't appear to be an enumeration for measurements

 Dim annotationEditor As New PdfAnnotationEditor()
                        annotationEditor.BindPdf(pFileName)
                        annotationEditor.DeleteAnnotations(Annotations.AnnotationType.Popup)

Can you offer a suggestion

VB.net 2015 Aspose total current release


Increase character spacing while replace text in PDF

$
0
0
while I try to replace text in pdf, the character spacing changed in the same line, I want to keep the same character spacing, any help ?

Open Type font support

$
0
0
I can find no definitive answer to this question. Does Aspose PDF support Open Type Fonts?

Aspose.PDF lost all the layers after optimize file size

$
0
0
We were looking for a 3rd party component to optimize PDF files, which will work like the “Save as optimized “ function in Adobe Acrobat Pro. In another words, keep all the layers info but reduce the file size. I tried Aspose PDF for .NET. Followed this link:
https://docs.aspose.com/display/pdfnet/Optimize+PDF+File+Size

It can reduce the file size but all the layers are lost.
Attached Test.pdf is the original file. TestOptimized.pdf was generated using Adobe Pro. TestOptimized.pdf is only 642k and it keeps all the layers. Can Aspose.pdf optimize Test.PDF and produce the same result as TestOptimized.pdf?

Thanks

Rose


Problem with textsegments not keeping colors

$
0
0
I am using the "segments" feature of a Text fragment. I create a textfragment and add several segments. The text appear as expected in the table cell - but not the properties. They appear as regular text (not bold, no colors). What am I doing wrong?

Code is below:

Dim t As Aspose.Pdf.Text.TextFragment = New Aspose.Pdf.Text.TextFragment 

Dim d1 As Aspose.Pdf.Text.TextSegment = New Aspose.Pdf.Text.TextSegment("MyText1")
 t.Segments.Add(d1)

Dim d2 As Aspose.Pdf.Text.TextSegment = New Aspose.Pdf.Text.TextSegment("MyText2")
d2.TextState.ForegroundColor = Aspose.Pdf.Color.White
d2.TextState.BackgroundColor = Aspose.Pdf.Color.Blue
d2.TextState.FontStyle = Aspose.Pdf.Text.FontStyles.Bold
t.Segments.Add(d2)

Row.Cells(1).Paragraphs.Add(t)

TIF file conversion issue

$
0
0
I have a problem with the attached TIF in that we get a blank page from the aspose conversion. Could this be investigated? We have tried the file against 11.3.0, 11.5.0 and (the latest) 11.7.0 versions and get the same result. Thanks, Adam

Making PDF Form Fields Read Only

$
0
0
We're using Java Aspose.PDF 16.10.0 to merge PDFs, but in the case of PDF forms we want to ensure that the form fields are read only (i.e. cannot be updated) in the final document.

The following post gave details of how to set the form fields to read only using the .NET version, I've tried to create code to match the solution in the 04-23-2012 3:58pm entry in Java

https://www.aspose.com/community/forums/thread/376789/not-getting-all-fields-in-pdf-forms.aspx

The relevant code snippet is as follows:

    for (Field field : pdfDoc.getForm().getFields()) {

        makeFieldReadOnly(field);

    }

    

    private static void makeFieldReadOnly(Field field) {

        field.setReadOnly(true);

        for (int i = 0; i < field.size(); i++) {

            makeFieldReadOnly((Field)field.get_Item(i));

        }

    }


The problem is that not all of the nested form fields are set to read only as they should be - I think it is because the field.size and field.get_item calls are not giving access to the child form fields as they should.


I'm attaching two documents to illustrate the problem:


original+form.pdf - This is the original PDF form

resulting+doc.pdf - This document is a merge of two of the above forms that has been processed using the above code snippet. If you look at the checkboxes you can see that some have correctly been set as read only, but some have not (the problem being that we need all the fields set to read only).


 


Converting Large TIF Images to PDF

$
0
0
We'd like to be able to support the conversion of large TIF images (up to 700MB) to PDF. Using Aspose.PDF seems to work well for images up to about 200MB, For larger images the Java call returns without an error after a lengthy period, but the PDF it returns is blank.

We're using version 16.10.0 and allowing 8GB of memory for the Java process. The applicable snippet of code is as follows:

        import com.aspose.pdf.Document;
        import com.aspose.pdf.Image;
        import com.aspose.pdf.Page;

        Document doc = new Document();
        Page page = doc.getPages().add();
        Image image = new Image();
        InputStream isImage = new FileInputStream(inputFile);
        image.setImageStream(isImage);

        page.getParagraphs().add(image);
        doc.save(outputFile);

We're testing with the following publicly available TIF images:

https://www.spacetelescope.org/static/archives/images/original/heic1206a.tif
https://www.spacetelescope.org/static/archives/images/original/heic0602a.tif

PageInfo.IsLandscape returning inaccurate Information

$
0
0
Hi!

Currently i try to figure out if every page of a PDF-Document is in Portrait/Landscape format.
I have found the Property "IsLandscape" at Aspose.PDF.Document.Pages.Page.PageInfo.IsLandscape.

How to use this functionality? 
I have a MS-Word Documet with a few A4-Pages, some in Portrait, some in Landscape format. Im saving this Document as a PDF and load it by using the Aspose.PDF.Document class.
If i iterate through every page and query the "IsLandscape" property... for every page it returns "FALSE" - Which is incorrect! - How do you determine this? By Rotation or checking the Page-Rectangle for its size?


Im using Aspose.Pdf .net "10.6.0.0"


Thanks in advance

Cell Border Issue

$
0
0
Hi,

We are trying to upgrade our version of Aspose.Pdf from version 4.1.1.0 (very old version) to 12.0.0.0. The reason we are upgrading is due to a bug putting a boxed border around the table of contents heading text. The behavior of the latest version has changed and does not seem correct. In the old version Example1 below would work correctly giving three rows with a left border, three rows with a top border, three rows with a right border, and three rows with a bottom border. The latest version does not put a top border. In the second example no borders are added. The only way to get the border to appear is if we set the first row's bottom border and the second row's top border.

        private void AddRow(Table pTable, BorderSide? pBorderSide)
        {
            Row vRow = pTable.Rows.Add();
            Cell vCell = vRow.Cells.Add();

            vCell.Paragraphs.Add(new Text(pTable.Rows.Count.ToString()));

            if (pBorderSide != null)
            {
                vCell.Border = new BorderInfo((int)pBorderSide.Value, 1, new Aspose.Pdf.Generator.Color(0));
            }
        }

        private Pdf Example1()
        {
            Pdf vPdf = new Pdf();
            Section vSection = new Section();

            Table vTable = new Table();

            this.AddRow(vTable, BorderSide.Left);
            this.AddRow(vTable, BorderSide.Left);
            this.AddRow(vTable, BorderSide.Left);

            this.AddRow(vTable, BorderSide.Top);
            this.AddRow(vTable, BorderSide.Top);
            this.AddRow(vTable, BorderSide.Top);

            this.AddRow(vTable, BorderSide.Right);
            this.AddRow(vTable, BorderSide.Right);
            this.AddRow(vTable, BorderSide.Right);

            this.AddRow(vTable, BorderSide.Bottom);
            this.AddRow(vTable, BorderSide.Bottom);
            this.AddRow(vTable, BorderSide.Bottom);

            vSection.Paragraphs.Add(vTable);
            vPdf.Sections.Add(vSection);

            return vPdf;
        }

        private Pdf Example2()
        {
            Pdf vPdf = new Pdf();
            Section vSection = new Section();

            Table vTable = new Table();

            this.AddRow(vTable, BorderSide.Bottom);
            this.AddRow(vTable, null);

            vSection.Paragraphs.Add(vTable);
            vPdf.Sections.Add(vSection);

            return vPdf;
        }

How FitToContent and IsWordWrapped in table and cell works

$
0
0
Hello,
Please refer attached PDF, I have set column adjustment property to auto fit to content.
And i have set IsWordWrapped property to false.

but it is wrapping the text.
I want column to be resized according to the largest fragment without word wrapping.
Like in attached document I want ABCD EFGH in single line only.

how this can be achieved?

Azure Storage

$
0
0
When using Aspose PDF for Cloud, are there any restrictions on what Azure Storage accounts can be used?

I keep getting the following error when trying to save a document using an Azure Storage configuration:

"Error: Windows Azure Storage exception: The value for one of the HTTP headers is not in the correct format.. Method: Create new document."

I don't seem to have a way to tell if this is because a setting is incorrect, or if there's some issue with the Azure Storage Client itself. Most information about this error seems to suggest it can be caused by an out of date Azure Storage Client, but I have no control over this.

There doesn't seem to be any documentation for how the settings should be specified for Azure, or what (if any) restrictions there are on the Azure Storage account setup itself.

Please could someone help me understand why I'm getting this error?

Text goes beyond cell definition when text includes certain characters

$
0
0
Hallo

I am using aspose pdf in order to fill in text in a table. I noticed that sometimes the text goes beyond the cell definition. I noticed that this happens when the text contains Japanese characters, for example. Text containing only English characters does not suffer from this problem, even inside the same table.

The code snippet below demonstrates this issue. There is one table and 2 cells with a lot of text. The text from the second cell contains some Japanese characters. The result is saved in the attachment: "Result.pdf".

List<String> inputStringList = new ArrayList<>();
        inputStringList.add("asd as   ADFWgsfgs df fg43 df a dad  a dsasd as   ADFWgsfgs df fg43 df a dad  a dsasd as   ADFWgsfgs df fg43 df a dad  a dsasd as   ADFWgsfgs df fg43 df a dad  a END");
        inputStringList.add("The signer signer1 in signing package 昨夜のコンサートは最高でし  has been manually authenticated. Passport authentication was completedEND");
       
        com.aspose.pdf.Document doc = new com.aspose.pdf.Document("Blank.pdf");
        com.aspose.pdf.Table table = new com.aspose.pdf.Table();
        table.getDefaultCellTextState().setFont(com.aspose.pdf.FontRepository.findFont("Helvetica"));
        table.setColumnWidths("400");
       
        for (String currentString : inputStringList) {
            Row row = table.getRows().add();
            row.getCells().add(currentString);
        }
       
        doc.getPages().get_Item(1).getParagraphs().add(table);
        doc.save("Result.pdf");

I noticed that removing the default font solves the problem, but I also need the table default font.
The same behavior is present under Windows and Linux.
The version of aspose.pdf is 11.8.0, but the problem is still present in the latest version.
Is this a bug? Is there any way to tweak the code in order to fix this problem?

Thank you,
Samuel

Issue with latest version of Aspose.Pdf dll

$
0
0
Hi Team,

I am having an issue while using the latest version (17.2.0.0) of Aspose.Pdf dll in my application.
I have a SharePoint 2013 application in which I have created a custom webpart. I have the following code in a button click event.
I have added the reference of Aspose.Pdf.dll from GAC (.Net framework 4.5).

    Aspose.Pdf.License license = new Aspose.Pdf.License();
                    license.SetLicense(ConfigurationManager.AppSettings[strPDFLicensePath]);
                    Aspose.Pdf.Generator.Pdf _pdf2 = new Aspose.Pdf.Generator.Pdf();
                    _pdf2.Security = new Aspose.Pdf.Generator.Security();
                    _pdf2.Security.IsCopyingAllowed = false;
                    _pdf2.Security.IsContentsModifyingAllowed = false;
                    _pdf2.Security.IsAnnotationsModifyingAllowed = false;
                    _pdf2.Security.IsScreenReadersAllowed = false;
                    _pdf2.Security.IsFormFillingAllowed = false;
                    _pdf2.Security.Is128BitsEncrypted = true;
                    _pdf2.PageSetup.Margin.Right = 98;// r = 50; no pagewidth; 
                    _pdf2.PageSetup.Margin.Left = 75;//70,68
                    //string strHTML = "<html><body><p>PDF text is here!</p></body></html>";
                    //_pdf2.BindHTML(strHTML);
                    //Create a section in the pdf document
                    Aspose.Pdf.Generator.Section sec1 = _pdf2.Sections.Add();
                    //add a sample text paragraph to paragraphs collection of section object
                    sec1.Paragraphs.Add(new Aspose.Pdf.Generator.Text("PDF text is here!"));
                    _pdf2.Save("D:\\TestPDF.pdf");
                    Aspose.Pdf.Document doc = new Aspose.Pdf.Document(_pdf2);
                    //doc.Encrypt("userpwd", "ownerpwd", 0, CryptoAlgorithm.AESx128);
                    doc.Save("D:\\TestPDFC.pdf");

The pdf never gets saved (or may be even created) at '_pdf2.Save("D:\\TestPDF.pdf");' line. Although no error is thrown.
At 'Aspose.Pdf.Document doc = new Aspose.Pdf.Document(_pdf2);' line below error is thrown 

Could not load file or assembly 'Aspose.Foundation, Version=17.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.

Can you please suggest on what could be missing?

Multiple text in fragment

$
0
0
Hi Team,

I am generating PDF using aspose java api. I like to combine different texts together in the same paragraph. For ex: i have a text followed by ------------------, a line to enter something and again text and a line to enter something. I tried to achieve this by adding fragement and having segments added to fragment. abut i am unable to add line to fragement. Also is there any way to mention font stlying for the entire PDF?


Thanks,
Gomathi R

Not able to flatten form and radio button and place form dynamically

$
0
0
Hi Team,

I am having a PDF which have editable and non-editable part.
My requirement is that I should be able to make the editable part non editable depending on a configuration.
I have added controls like CheckboxField, RadioButtonOptionField, TextBoxField.
These controls  I have added to a table which suits my requirement.

Is it necessary that I have to add the editable control to a Form?
If I add it to form the control shows up in two place. One in the table where I have placed according to the pdf design and also on the first page as  I am adding to pdf.getForm().add(field, 1)

If  I don't place the fields in the form  I would not be able to flatten the PDF to make it non editable.
I am also not able to add the table to the Form as it allows only field item.
As per requirement I would not be able to place the form in any static location like Rectangle as my data remains dynamic and can grow to any extend.

Please let me know if there is a way to make the form visibility false so that non of my fields are repeated twice, also please let me know if there any work around.

Code:
static void Create() throws FileNotFoundException
{
Booleam isPdfEditable = false;
pdfDoc = new Document();
pdfPageItem = pdfDoc.getPages().add();
pdfPageItem.getParagraphs().add(NonEditableContent()); --- > Implementation not provided in code
pdfPageItem.getParagraphs().add(GetTable()); 
if(!isPdfEditable)
        {
            pdfDoc.flatten();
            pdfDoc.getForm().flatten();
            Field[] fields = pdfDoc.getForm().getFields();
            for(Field field : fields)
            {
                field.flatten();
            }
        }
pdfDoc.save("Sample.pdf");

}

 private static Table GetTable()
        {
               Table questionTable = new Table();
               questionTable.setMargin(pdfDoc.getPageInfo().getMargin());
               questionTable.setColumnWidths("20 500");
               RadioButtonField rf = new RadioButtonField(pdfDoc);
               rf = new RadioButtonField(pdfPageItem);
               rf.setPartialName("radio");
               Row r2 = questionTable.getRows().add();
               Cell c2 = r2.getCells().add();
               Cell c3 = r2.getCells().add();
                
                  
               c2.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Top);
               c2.setWordWrapped(true);
               c3.setVerticalAlignment(com.aspose.pdf.VerticalAlignment.Bottom);
               c3.setWordWrapped(true);
                  

                RadioButtonOptionField opt1 = new RadioButtonOptionField();
                opt1.setOptionName("Name");
                opt1.setWidth(10);
                opt1.setHeight(10);       
                rf.add(opt1);
                pdfDoc.getForm().add(opt1, 1);
               
                RadioButtonOptionField opt2 = new RadioButtonOptionField();
                opt2.setOptionName("Name");
                opt2.setWidth(10);
                opt2.setHeight(10);       
                rf.add(opt2);
                pdfDoc.getForm().add(opt2, 1);
               
                c2.getParagraphs().add(opt1);
                c3.getParagraphs().add(opt2);

                CheckboxField chk1=  new CheckboxField(pdfDoc);
                   chk1.setPartialName("ch");
                   chk1.setWidth(10);
                   chk1.setHeight(10);
                  
                   Border border = new Border(chk1);
                   border.setWidth(2);
                   border.setStyle(BorderStyle.Solid);
                   chk1.setBorder(border);
                   chk1.getCharacteristics().setBorder(java.awt.Color.BLACK);
                   pdfDoc.getForm().add(chk1, 1);
                  
                   TextBoxField textBoxField1 = new TextBoxField(pdfDoc);
                textBoxField1.setPartialName("tb");
                textBoxField1.setHeight(30);
                textBoxField1.setWidth(500);
                textBoxField1.setInLineParagraph(true);
                textBoxField1.setMultiline(true);
                pdfDoc.getForm().add(textBoxField1, 0);
                  
               Row r3 = questionTable.getRows().add();
               Cell c4 = r3.getCells().add();
               Cell c5 = r3.getCells().add();
              
               c4.getParagraphs().add(chk1);
               c5.getParagraphs().add(textBoxField1);
              
               return questionTable;
                          
           }

RightToLeft (RTL) lang support broken for pdf?

$
0
0
Hi.

I'm trying to export to pdf using RTL functionality, ie for RTL languages such as arabic. There is quite a few "IsRightToLeft" flags and I'm basically just setting all of them for now. However, it doesn't seem to do anything at all.

Here is some example/test code for a simple table:
Table table = paragraph as Table;
foreach (Row row in table.Rows) {
foreach (Cell cell in row.Cells) {
foreach (Paragraph cellParagraph in cell.Paragraphs) {
Text text = cellParagraph as Text;
foreach (Segment segment in text.Segments) {
segment.TextInfo.IsRightToLeft = true;
}
}
}
}

I also tried the following properties:
Pdf pdf = new Pdf();
pdf.IsRightToLeft = true;
pdf.IsRtlInSegmentMode = true;
pdf.TextInfo.IsRightToLeft = true;
foreach (Section section in pdf.Sections) {
section.TextInfo.IsRightToLeft = true;
}

What I expect to happen is that the text alignment should probably change and that cells for the table should be in reverse order. Same as the attached screenshot in this forum post.

What is actually happening is nothing. It looks exactly the same as it did without setting any of these properties. What am I missing?

IsHtmlTagSupported

$
0
0
I am currently evaluating version 17.2 with the view to upgrading our Aspose Pdf from our current version of 3.8.

We make extensive use of XML templates and HTML text and I have run across a small problem that I need help with, if you would be so kind.

Consider the following XML fragment:

<?xml version="1.0" encoding="utf-8"?>
 <Pdf xmlns="Aspose.Pdf">
   <Section>
       <Text>
         <Segment FontName="Tahoma" FontSize="10">
           Test string
         </Segment>
       </Text>
   </Section>
 </Pdf>

This gives the expected PDF with the text in Tahoma font of size 10pt.

Now consider the following XML:

<?xml version="1.0" encoding="utf-8"?>
 <Pdf xmlns="Aspose.Pdf">
   <Section>
       <Text IsHtmlTagSupported="true">
         <Segment FontName="Tahoma" FontSize="10">
           Test string
         </Segment>
       </Text>
   </Section>
 </Pdf>

This does not work as expected, the text seems to be in Times New Roman. Now reading prior posts I see that I have to use two other properties to get this to work, so consider the last XML:

<?xml version="1.0" encoding="utf-8"?>
 <Pdf xmlns="Aspose.Pdf">
   <Section>
       <Text IsHtmlTagSupported="true" 
IfHtmlTagSupportedOverwriteHtmlFontNames="true"
IfHtmlTagSupportedOverwriteHtmlFontSizes="true">
         <Segment FontName="Tahoma" FontSize="10">
           Test string
         </Segment>
       </Text>
   </Section>
 </Pdf>

This gives me the error:

Unknown attribute in Text element. The attribute name is IfHtmlTagSupportedOverwriteHtmlFontNames.

My question is what am I doing wrong?

Thanks.

Issue with Aspose.PDF version 16.12

$
0
0
Hi there
We are currently using Aspose.PDF (version 11) in production as part of a SharePoint custom page. Our libraries are deployed to the GAC. There is a defect that's been resolved by version Aspose.PDF version 16.12, however, when we reference the latest DLL, the following error occurs during runtime. 

Could not load file or assembly 'Aspose.Font, Version=16.12.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.

Here is the example code:
 var excelStream = new FileStream(@"C:\temp\test.xlsx", FileMode.Open);
 var pdfStream = new MemoryStream();
 var wb = new Workbook(excelStream);
        
 wb.Save(pdfStream, SaveFormat.Pdf);
 var doc = new Aspose.Pdf.Document(pdfStream);
 doc.Save(@"C:\temp\upgradetest.pdf");


The exception occurs on the doc.Save line.

When we set the deployment target for Aspose.PDF.dll to WebApplication (local) instead of the GAC, the exception does not occur.

I suspect that there may be an issue with  missing references or and issue with security access to the GAC assembly from a SharePoint page.

This is an urgent matter as it involves our production deployment. I appreciate a prompt response.

Thanks

Exception Message: Could not load file or assembly 'Aspose.Pdf, Version=9.1.0.0

$
0
0

We installed provided package with Aspose trial license. During POC, we observed PDF generation failed and we got following errors in SharePoint logs.

 10/02/2017 06:10:49 --  Exception Source: SABMiller.BTF.Application Exception Message: Could not load file or assembly 'Aspose.Pdf, Version=9.1.0.0, Culture=neutral, PublicKeyToken=47b2d0fcacdd3eb6' or one of its dependencies. The system cannot find the file specified. Exception StackTrace:    at SABMiller.BTF.Application.PDFGeneration.renderPDF(SPListItem CurrItem, String Filter)

   at SABMiller.BTF.Application.PDFGeneration.<Page_Load>b__0()

   at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass4.<RunWithElevatedPrivileges>b__2()

   at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)

   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)

   at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)

   at SABMiller.BTF.Application.PDFGeneration.Page_Load(Object sender, EventArgs e) on10/02/2017 06:10:49

While in our current SP 2010 farm, Aspose 9.1.0.0 dll is present in Windows GAC and PDF generation is working fine.We are using "Aspose Total for .NET" license there.

In new SP 2010 farm, Aspose 9.1.0.0 dll  is missing and causing issues. 

In which setup we can find "Aspose 9.1.0.0 dll"?

Thanks in advance.

Viewing all 1038 articles
Browse latest View live