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

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");

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
 

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

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

How to change PDF Metadata

$
0
0
I need to change the generated PDF meta data after stamping it 
this is the code

string dataDir = @"D:\folder\";

            // Open document
            string filename = "file";
            Document pdfDocument = new Document(dataDir + filename + ".pdf");
            

            // Create text stamp
            TextStamp textStamp = new TextStamp("Test Text");
            // Set whether stamp is background
            textStamp.Background = true;
            // Set origin
            textStamp.XIndent = 40;
            textStamp.YIndent = 150;
            // Rotate stamp
            textStamp.RotateAngle = 45;
            // Set text properties
            textStamp.TextState.Font = FontRepository.FindFont("MyriadPro-Bold");
            textStamp.TextState.FontSize = 130;
            textStamp.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.LightGray);
            // iterate through all pages of PDF file
            for (int Page_counter = 1; Page_counter < pdfDocument.Pages.Count; Page_counter++)
            {
                //add stamp to all pages of PDF file
                pdfDocument.Pages[Page_counter].AddStamp(textStamp);
            }
            string data = pdfDocument.Info.Creator;
            Console.WriteLine(data);
            dataDir = dataDir + "out.pdf";
            // Save output document
            pdfDocument.Save(dataDir);

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

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.

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

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 

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

PDF to PDF conversion with image downsampling

$
0
0
Hi,
  I'd like to know if it's possible to save a PDF file into another one, downsampling images.

Thanks.

Add Image as annotation to PDF

$
0
0
Is it possible to take an signature image and add it to an existing PDF document as a stamp?  If it is possible can the image be overlaid so that it could appear on a signature line in the PDF Document? 

Grouped Check-boxes code not working

$
0
0
Hello,

Sample code provided in the link code to generate grouped check-boxes is not working. I have attached the generated PDF. Kindly let us know what is wrong. 

http://www.aspose.com/docs/display/pdfnet/Add,+Delete+and+Modify+Form+Field#Add%2CDeleteandModifyFormField-HowtoaddGroupedCheckboxes

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);
                    _pdf2.Save("D:\\TestPDF.pdf");
             
I am getting the exception at the line _pdf2.BindHTML(strHTML)
Exception: Could not load file or assembly 'Aspose.HtmlOld, Version=17.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.

Note that the same code work fine in .Net Console application. But, with WebApplication, I am facing this issue. 
Can you please suggest on what could be missing?
Any quick help on this is much appreciated.

PDF Split Sample Source code based on the PDF file Size

$
0
0
Hello PDF Product Team, We have folder with 1000 Color Images. We need to create PDF files with 50MB or Configured MB file size. Please can you share some Source code for this PDFs Creation. Can we find out how many PDFs can be created with each PDF size of 50MB for 1000 Color images? This information we need to get before saving or Creating the actual PDFs. Thanks, P. Saravanan.

PDF File with Signature

$
0
0
Hi Aspose,

I am using Aspose.Pdf version 9.7.0.0. I am trying to insert a pdf pages on another pdf using following code 

pdfDocument.Pages.Insert(item.InsertAtPage, item.Document.Pages);

but one of the page of item.Document.Pages (which is pdf document pages) has embedded signature on it, which throws an exception:

Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.

If pdf file does not have embedded signature, it works fine. Can you please help me how to resolve this problem?

Regards

Yasser Ahsan

PDF to HTML problem when viewing html in Edge browser.

$
0
0
I am using version 17.4 of Aspose.Pdf.
We are converting documents from PDF to HTML for display in a web application.

For some documents, it appears there is a problem when viewing in Edge.
The image is obscured by the text unless you resize the browser window just so.

Firefox, Chrome, IE 10 and IE 11 do not show such an issue.
We are saving to a single stream with embedded resources using code similar to the documentation samples.

Is this known behavior in the Edge browser and do you have a way to work around the issue?

I have attached an example of the PDF and the generated HTML in a zip file.

Thanks,
Patrick

mergeing pdfs doesn't work!

$
0
0
I need to merge 2 different PDFs to 1. I tried append method from com.aspose.pdf.kit.PdfFileEditor but it doesn't work. Following is my code:

File target = PDFUtil.createTempFile();
FileOutputStream os = new FileOutputStream(target);
FileInputStream inpuStream1= new FileInputStream(f1);
FileInputStream inpuStream2= new FileInputStream(f2);
com.aspose.pdf.kit.PdfFileEditor editor = new com.aspose.pdf.kit.PdfFileEditor();
editor.append(inputStream1, portStream2, 1, 1, os);
os.flush();

I am pretty sure both f1 and f2 are valid pdf because I tried to concatenated them by "pdfDocument.getPages().add(addPageDocument.getPages())" it can successfully glued 2 PDFs in seprate pages but I need merge them into 1 pdf. 
Viewing all 1038 articles
Browse latest View live