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

Aspose.PDF gives me an 'out of memory' error on trying to process large PDF file

$
0
0
Hi,

I am getting  'out of memory' error on trying to convert large PDF 164 MB (about 6000 pages) into single page tiffs. I am using 11.2.0. 0 version of Asp.PDF.dll.

Here is the code i am using

// bind the pdf document
                Aspose.Pdf.Facades.PdfExtractor pdfExtractor = new Aspose.Pdf.Facades.PdfExtractor();
                pdfExtractor.BindPdf(fileToProcess.FullName);

                // set page range for image extraction
                //pdfExtractor.StartPage = 1;
                Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(fileToProcess.FullName);
                int pageCount = pdfDocument.Pages.Count;

 // create Resolution object with 300 as an argument
                    Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300);

                    //create TiffSettings object
                    Aspose.Pdf.Devices.TiffSettings tiffSettings = new Aspose.Pdf.Devices.TiffSettings();
                    tiffSettings.Compression = Aspose.Pdf.Devices.CompressionType.CCITT4;
                    tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
                    //tiffSettings.Shape = Aspose.Pdf.Devices.ShapeType.Portrait;
                    tiffSettings.SkipBlankPages = false;
                    //create TIFF device
                    Aspose.Pdf.Devices.TiffDevice tiffDevice = new Aspose.Pdf.Devices.TiffDevice(resolution, tiffSettings);

 int i = 0;
                    for (i = startPageCount; i <= endPageCount; i++)
                    {

                        //var converter = new Aspose.Pdf.Facades.PdfConverter();
                        //converter.BindPdf(fileToProcess.FullName);
                        //converter.StartPage = i;
                        //converter.EndPage = i;
                        //converter.DoConvert();
                        pdfExtractor.StartPage = i;
                        pdfExtractor.EndPage = i;
                        pdfExtractor.ExtractImage();

                        while (pdfExtractor.HasNextImage())
                        {
                            Console.WriteLine("Getting next image....");
                            // save image to stream
                            MemoryStream imageStream = new MemoryStream();
                            pdfExtractor.GetNextImage(imageStream);
                            imageStream.Position = 0;

                            strNewDirectory = "C:\\AFLAC_Processing\\XDS Exporter\\Export\\Agent Services";
                            strNewImage = i.ToString("00000") + ".TIF";
                            tiffDevice.Process(pdfDocument, i, i, strNewDirectory + @"\" + strNewImage);

}
}

aspose.pdf TextFragmentAbsorber to use existing form

$
0
0
hi,

I would like to check if it is possible to set the aspose.pdf to replace the text with existing pdf font?

currently we have multiple pdf templates and each template use different fonts. 
Each pdf has specific words (e.g. _Name_) which is to be replaced with database value.

at the moment, when change the _Name_ to client user, the text font/size looks different from the original font/size.

Thanks
 

Embed glyphs into PDF

$
0
0
Hallo

Is it possible to embed only used glymphs into the PDF?
I searched through the documentation, but only found something like RemoveDuplicatedFonts and RemoveSimilarFontsWithDifferentWidths. That is not what I want.
I want to know whether it is possible to tell aspose to embed only the glyphs that are actually used, instead of the whole font.

The problem I have is that the PDF gets very large when using certain fonts. If I use "NotoSansCJKjp-Regular" font from Google Noto Fonts, the document increases in size with more than 10MB.

The code snippet below demonstrates this issue. There is one table and 2 cells with some text. The result is saved in the attachment: "ResultNoto.pdf".
If I comment out the line of code that specifies usage of "NotoSansCJKjp-Regular", the resulting PDF more than 10MB smaller: "Result.pdf".
The files are attached and the sample code is below:

        List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
        fontPaths.add("C:\\temp\\Noto-hinted");
        com.aspose.pdf.Document.setLocalFontPaths(fontPaths);
        
        List<String> inputStringList = new ArrayList<>();
        inputStringList.add("äöüß é ç Здравствуйте 3 df a dad  a END");
        inputStringList.add("äöüß é ç Здравствуйте  昨夜のコンサートは最高でし adsf dfg END");
        
        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("NotoSansCJKjp-Regular"));
        table.setColumnWidths("400");
        
        for (String currentString : inputStringList) {
            Row row = table.getRows().add();
            row.getCells().add(currentString);
        }


I am using aspose.pdf verson 11.8.0
        
Thank you,
Samuel

Replaced content not reflowing

$
0
0
When using find and replace in an existing pdf document, we found that Aspose pdf is not re-flowing the content and, as such, some content is overlaying or leaving large blank areas.  In the documentation it is stated that this issue does not occur, but as of which version?  We are using 6.9.0.0 in an established application.

Attached are images to explain what I mean.

Hyperlink in HtmlFragment Text

$
0
0
Hi,

I would like to know, how to enable hyperlinks in a HtmlFragment Text. The scenario is as below

I am having a HTML content coming from a different source, I have to display the content as it is, I am displaying the Same HTML content in PDF using HtmlFragment in a document. The hyperlinks in the text are getting enabled. Please suggest, how to proceed further. Attached is the output file generated from ASPOSE. Code for the same is as below:

            var dataDir = AppDomain.CurrentDomain.BaseDirectory;
            var lic = new Aspose.Pdf.License();
            lic.SetLicense("Aspose.Pdf.lic");

            Document doc = new Document();
            var page = doc.Pages.Add();
            TextStamp textStamp = new TextStamp("Hello word");


                      HtmlFragment title1 = new HtmlFragment("Hello World, this is a link to go to<a href='www.google.com'>Google</a> Click here");

            title1.HtmlLoadOptionsOfInstance = new HtmlLoadOptions();
            page.Paragraphs.Add(title1);
            //title1.IsInNewPage = true;
            // Add HTML Fragment to paragraphs collection of page
            textStamp.TopMargin = 10;
            textStamp.HorizontalAlignment = HorizontalAlignment.Center;
            textStamp.VerticalAlignment = VerticalAlignment.Top;

            string s3 = "<h3 style='font-family:Verdana;font-size:larger;font-size:20px'>Raj</h3><br/> <Ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li></ul>";

            HtmlFragment title2 = new HtmlFragment(s3);
            page.Paragraphs.Add(title2);

            doc.Save(dataDir + "abc.pdf");
            Document doc1 = new Document(dataDir + "abc.pdf");
            //Add header on all pages
            foreach (Page tpage in doc.Pages)
            {
                tpage.AddStamp(textStamp);
            }
            doc.Save(dataDir + "abc.pdf");


Regards,
Raj.

Error while converting html page to pdf

$
0
0
Hi Team, 

I am trying to convert html page using url to pdf but this exception occures-

An unhandled exception of type 'System.ArgumentException' occurred in Aspose.Pdf.dll

Additional information: At most 4 text fragments can be added in evaluation mode.


Code:

  WebRequest request =WebRequest.Create("https://www.sec.gov/Archives/edgar/data/320193/000119312517003764/d307349ddefa14a.htm");
            // If required by the server, set the credentials.
            request.Credentials = CredentialCache.DefaultCredentials;
            
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            Stream dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();
            reader.Close();
            dataStream.Close();
            response.Close();

            MemoryStream stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(responseFromServer));
            HtmlLoadOptions options = new HtmlLoadOptions("https://www.sec.gov/Archives/edgar/data/320193/000119312517003764/");

            Document pdfDocument = new Document(stream, options);

            options.PageInfo.IsLandscape = true;

            pdfDocument.Save( @"C:\HTMLtoPDF_DOM.pdf");

RadioButtonOptionField Crashes when trying to place in Tabel Cell

$
0
0
Hi Team,

I am trying to add RadioButtonOptionField to a tabel cell, But it is throwing the NullPointerException. I don't want to mention Rectangle parameter because i need to add it to a table cell  than fixing the position using rectangle.

Version: aspose.pdf-16.10.0.jar

Error:
   at com.aspose.pdf.Annotation.m1(Unknown Source)
   at com.aspose.pdf.WidgetAnnotation.m1(Unknown Source)
    at com.aspose.pdf.Field.m1(Unknown Source)
    at com.aspose.pdf.Annotation.m1(Unknown Source)
    at com.aspose.pdf.RadioButtonField.add(Unknown Source)

Code:
Table table = new Table();
table.setMargin(new MarginInfo(20, 20,10, 0));
table.setColumnWidths("50 50");
pdfPageItem.getParagraphs().add(table);

RadioButtonField radio = new RadioButtonField(pdfPageItem);
RadioButtonOptionField opt1 = new RadioButtonOptionField(); -- > Null exception here
opt1.setOptionName("Test1");
opt1.setName("Test1");
opt1.setCaption(new TextFragment("Test1"));

Row row = table.getRows().add();
Cell cellYesField = row.getCells().add();
cellYesField.getParagraphs().add(opt1);

pdfDoc.getForm().add(radio);
pdfDoc.save("Sample.pdf");

Please let me know how i can add the options to a table cell rather than using fixed coordinates using rectangle.

Thanks,
Leena Robert

How to set ImageFileType for Image

$
0
0

Hi Team,

 I am getting image as bytes from  database and that bytes may be of a png or jpeg mage.

How can  specify the ImageFileType for an Image control in pdf.

       Document pdfDoc = new Document();

       pdfDoc.getPageInfo().getMargin().setLeft(10);

       pdfDoc.getPageInfo().getMargin().setRight(20);

       pdfDoc.getPageInfo().getMargin().setTop(10);

       pdfDoc.getPageInfo().getMargin().setBottom(10);

       pdfDoc.getPages().add();

      

Image img1 = new Image();

       img1.setFixHeight(50);

       img1.setFixWidth(50);

             

ByteArrayInputStream bstream = new ByteArrayInputStream(bytes);

       img1.setImageStream(bstream);

      

       pdfPageItem.getParagraphs().add(img1);

       pdfDoc.save("Sample.pdf");


Thanks

Leena Robert


How to set background colour of a FreeTextAnnotation

$
0
0
Is it possible to set the background colour of a FreeTextAnnotation? I can set the font colour through the DefaultAppearance but I'm struggling to set the background colour. 

Pdf.InteractiveFeatures.DefaultAppearance appearance =
    new Pdf.InteractiveFeatures.DefaultAppearance("Arial", fontSize, color);
Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation annotation =    new Pdf.InteractiveFeatures.Annotations.FreeTextAnnotation(page, new Pdf.Rectangle(llx, lly, urx, ury), appearance);

TIA
Dan

Table Page Break (PDF)

$
0
0

Hello!

I am trying to stop Aspose PDF from page breaking in the middle of a table in C# .NET. I have not found any answers that have solved this problem through Google, Stackoverflow, or this forum.

We have a table with two rows that must always be together as they are utilized as a header. These rows are currently being split sometimes when they happen to fall on a page break. I wish to stop this from happening.

I have found the table.isBroken attribute always returns true and row.isRowBroken always returns false (from Aspose). This does not help me to stop the page from breaking in the middle of this table.

Here is a link to the post on stackoverflow: http://stackoverflow.com/questions/42079506/do-not-page-break-on-table-in-aspose-pdf-c-sharp-asp-net

Thank you for your time!

PDF Margin info giving me same values always

$
0
0

I am using Aspose.pdf trial version . PageInfo.Margin always giving me same data for all pdfs .Top and Bottom Margins is always 72 point ,Left and Right Margins is always 90 pt 

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;
                          
           }

Is relative css possible with Aspose when converting pdf to html?

$
0
0
Hi,

I have a situation where pdfs needs to be translated to different languages. The process is to first convert it into html and the pass the html as input to translator API. Translator returns the translated html with original html tags intact. Now if the translated text isn't of the same size of text in original language then overlapping happens and the readability is affected. So want to know if relative stylingpossible with Aspose. Attaching picture of position styling generated by Aspose.

Regards,
Amit

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

PDF signing questions (multiple Digital Signatures (PKI)) PAdES support

$
0
0
Does Aspose PDF support digital signing a PDF that already has a digital signature without invalidating the first signature?  I believe this is referred to as Serial Signing

Example: A PDF is authored by a third party and signed to authenticate the author.  We want to append some additional information then apply our signature.  We would like both signatures to be intact, the signature on the original portion of the document and the signature on the whole (outer) document.

iText supports this as it supports PAdES (PDF Advanced Electronic Signatures) 

.net standard

$
0
0
Hi,

Is there any plan to support the .Net Standard or netcoreapp ?

Thanks in advance, 

Alexandre Swioklo

Verifying the TextStamp

$
0
0
Hi There,

We are using Apose PDF Java library to apply TextStamps, and it is working fine with no issues. What I want to do is add some unit tests to verify that TextStamps are there. 
Can you please direct me to some code which reads the text stamps so that I can verify?

Thanks,
Manish

Need more clarity on specific functionality before purchase

$
0
0
We are planning propose this product to our client. I went through all the PDF and Cells documents and tried POC on this same.

However given document does not given much clarity on few of my specific requirement, So I would like to speak to any of the expert whether my requirement is supported or not.

My requirement:
Aspose.PDF
1.Convert Plain HTML template to PDF containing bar Chart.
2.Convert Plain HTML template with CSS and JavaScript to PDF containing bar Chart.



My conatct No : +91-9176237971
My mail ID : magesh.murugesan2@cognizant.com

restart page numbering

$
0
0
Hello, I have different sections in my document, I want to restart page numbers for each section, I would like to know how to do it, Is there any property like IsPageNumberRestarted which we used to have in Generator. I have one solution where I can create new document for each section and merge them later, but I don't want to go this way. Could you please suggest me any another way

dpi or ppi set feature for aspose.pdf or aspose.image

$
0
0
is it possible to set the dpi for pdf file or set the dpi for the image in the pdf file? If it's yes, then is there any way to locate the image in each page of the pdf file, so that I can fetch that page's image to process dpi and do compress without quality loss, and finllay I can get the small size of the pdf file
Viewing all 3131 articles
Browse latest View live