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

Header is upside-down, backward and at bottom when built through HtmlFragment

$
0
0
Trying to add header content dynamically.  Our body is a dynamic HTML, and that's working mostly fine using the new DOM approach.  I added a fixed footer with the page numbers and that's also fine.  When I add a header with an HtmlFragment, however, the content of the header appears at the bottom of the page, rendered upside down and backward.  It also appears to push the footer off the page in most cases, and PDFReader reports, "An error exists on this page ...".  I tried swapping the header and footer and got no header/footer at all.  I tried using my full, complex, HTML as well as a small, simple HTML, and nothing worked.  Any way to make this work?

Substance of the code is below, sample HTML and result attached:
            //load
            HtmlLoadOptions htmloptions = new HtmlLoadOptions();
            Document doc = new Document(filepath, htmloptions);

            //header
            using (OpenFileDialog ofd = new OpenFileDialog() { Title = "Select Header HTML", InitialDirectory = _mypath, Filter = "web doc|*.html;*.htm;*.txt" })
            {
                if (ofd.ShowDialog().Equals(System.Windows.Forms.DialogResult.OK))
                {
                    using (StreamReader sr = System.IO.File.OpenText(ofd.FileName))
                    {
                        Aspose.Pdf.HeaderFooter header = new Aspose.Pdf.HeaderFooter();
                        header.Paragraphs.Add(new HtmlFragment(sr.ReadToEnd()) { IsInLineParagraph = true });
                        for (int cnt = 1; cnt <= doc.Pages.Count; cnt++)
                        {
                            doc.Pages[cnt].Header = header;
                        }
                        sr.Close();
                    }
                }
            }
            //footer
            Aspose.Pdf.HeaderFooter footer = new Aspose.Pdf.HeaderFooter();
            footer.Paragraphs.Add(new TextFragment("Page $p of $P ") { HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Right });
            for (int cnt = 1; cnt <= doc.Pages.Count; cnt++)
            {
                doc.Pages[cnt].Footer = footer;
            }

            //output
            using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "PDF|*.pdf", InitialDirectory = _mypath })
            {
                if (sfd.ShowDialog().Equals(DialogResult.OK))
                {
                    _FileName = sfd.FileName;
                    doc.Save(sfd.FileName);
                }
            }

Issues after publishing to Azure Websites

$
0
0
Hello, this is my 1st post here.  We have the need to dynamically create high quality PDFs from an Azure WebAPI method so I have downloaded the trial version and created a simple test .Net project and .aspx page as a proof of concept.  This proof of concept works on my local dev machine; however, after I publish to a test Azure Websites website it no longer works and errors.  I am guessing this is an issue related to our use of the Arial fonts which might not be available in the shared Azure Websites environment.

This simple test works great locally ( I have the ttf files); however, in Azure it crashes when it encounters the  pdf.Save(finalStream); statement.  I have attempted to add the various Arial ttf files to the fonts folder with Build Actions of "Content" and "Embedded Resource" but it still crashes. 

If I comments out the following 2 lines from the BuildSection1 method it works fine except it uses the default font, not the Arial Narrow.

                seg1.TextInfo.FontName = "Arial Narrow";
                seg1.TextInfo.IsTrueTypeFontBold = true;

Here are the relevant code snippets, the control method calls BuildSection1() then StreamPDF() to stream the PDF 

        protected void BuildSection1()
        {

            try
            {
                Aspose.Pdf.Generator.Section sect1 = pdf.Sections.Add();
                sect1.BackgroundImageFile = Server.MapPath("~/Images/Background.jpg");           
                Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sect1);           
                sect1.Paragraphs.Add(t1);
                Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
                seg1.Content = "This is content added to seg1.Content...";

                // note: if I comment the following 2 lines and publish to azure everything works except it uses the default font.
                // note: everything works fine locally and the proper font is used; however, the pdf.Save(finalStream); command below blows up in Azure when a font is selected
                seg1.TextInfo.FontName = "Arial Narrow";
                seg1.TextInfo.IsTrueTypeFontBold = true;
                seg1.TextInfo.IsFontEmbedded = true;

                seg1.TextInfo.Color = new Aspose.Pdf.Generator.Color("red");
                seg1.TextInfo.FontSize = 12;
                t1.Opacity = 1F;
                t1.Segments.Add(seg1);
            }
catch (Exception) { throw; }
}
        protected void StreamPDF(string documentTitle)
        {
            try
            {
                System.IO.MemoryStream finalStream = new System.IO.MemoryStream();
                pdf.Save(finalStream);//note pdf var was defined globally in the real code...
                byte[] downloadBytes = finalStream.ToArray();
                HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");
                HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + documentTitle + ".pdf");
                HttpContext.Current.Response.BinaryWrite(downloadBytes);
                HttpContext.Current.Response.End();
            }
            catch (Exception) { throw; }
}

Is there a better way to use fonts and publish them to Azure?

Thanks...

Aspose.PDF (PCL to PDF) for Java on UNIX/LINUX looks for hard-coded paths such as /usr/share/fonts/truetype/msttcorefonts/ and /usr/X11R6/lib/X11/fonts/truetype/msttcorefonts/

$
0
0
The paths for Aspose.PDF for msttcorefonts are hard-coded as /usr/share/fonts/truetype/msttcorefonts/ and/or  /usr/X11R6/lib/X11/fonts/truetype/msttcorefonts/.  There should be a way to overrided their location.

This comes up when generating PDF from PCL.

rectangle Box coordinates are incorrect

$
0
0
Dear support,

I am using attached document (test_esign.pdf) to extract some custom rectangle boxes for a regex text. Notice the text in page 3 that looks like this: {{t:s;r:y;o:"Insured";}}
I noticed that the LLX, LLY,URX,URY appear to be huge like 2498/2101/3316/2207 when they are expected to be under 1000 number.

1. Is this a bug?
2. Why are the coordinates of the textfragment so high and
3. what is a solution for me to solve this and obtain correct coordinates?

-        Rectangle    {2498.736,2101.496,3316.08,2207.096}    Aspose.Pdf.Rectangle
        Height    105.59999999999991    double
        IsEmpty    false    bool
        IsPoint    false    bool
        IsTrivial    false    bool
        LLX    2498.736    double
        LLY    2101.496    double
        URX    3316.08    double
        URY    2207.096    double
        Width    817.344    double

Thank you,
Sireesha

Aspose.Pdf.Image

$
0
0
http://www.aspose.com/docs/display/pdfnet/Add+SVG+Object+to+Table+Cell

I was trying the below example and it throws an error:

 

1.      'Aspose.Pdf.Image' does not contain a definition for 'FileType' and no extension method 'FileType' accepting a first argument of type 'Aspose.Pdf.Image' could be found (are you missing a using directive or an assembly reference?)

2.      The type or namespace name 'ImageFileType' does not exist in the namespace 'Aspose.Pdf' (are you missing an assembly reference?              

 

            // Create an image instance

            Aspose.Pdf.Image img = new Aspose.Pdf.Image();

            // Set image type as SVG

            img.FileType = Aspose.Pdf.ImageFileType.Svg;

How to add a JPG or PNG to a a Cell ? (Aspose.Pdf.Document)

$
0
0
How to add a JPG or PNG to a a Cell ? Using Aspose.Pdf.Document

http://www.aspose.com/docs/display/pdfnet/Add+SVG+Object+to+Table+Cell


Draw line under text

$
0
0
Hi,
I want to draw line under the text (not required classic underlined text, I'll set the color and height of the line). I have TextFragment object by TextFragmentAbsorber.TextFragments. I've tried to create Graph and draw line and could not position the line on the correct place. 
First, what is the correct method? Second, what am I missing to calculate the position? Could you please supply a sample code?
My method is like that:
graph = new Aspose.Pdf.Drawing.Graph((float)textFragment.Page.Rect.Width, (float)textFragment.Page.Rect.Height);
Aspose.Pdf.Drawing.Line line = new Aspose.Pdf.Drawing.Line(new float[] { (float)textFragment.Rectangle.LLX, (float)textFragment.Rectangle.LLY, (float)textFragment.Rectangle.LLX + (float)textFragment.Rectangle.Width, (float)textFragment.Rectangle.LLY});

Thank you

PDF not displaying images

$
0
0
When we are creating a large PDF file, we instantiate the pdf with a file stream like so

new Pdf(new FileStream());

With each section that we add to the Pdf, we use Section.AddParagraph(p); instead of Section.Paragraphs.Add(p);

Doing this causes any images that we add to the paragraph to not display. If we use the other way (Section.Paragraphs.Add(p)) and call Pdf.Save() instead of Pdf.Close(), the images display fine. 

Is there anything we can do about this?

Thanks.

Printing/Sending PDF in Postscript to printer

$
0
0
Hi, We have a .net application that must take a multitude of PDF files and send this to Postscript printer which only have an IP address. We are using the aspose plugin for the conversion of the PDF files to postscript but how do you send the postscript file to the printer for printing.

We are not allowed to install the printer interface so we can only communicate through the IP and postscript.

Any help would be appreciated.

Replacing text using Aspose.Pdf.Facades.PdfContentEditor

$
0
0
Hi,

We are using Aspose Pdf Version 7.2.0.0 to replace text in PDF files with the PdfContentEditor.
Attached is the PDF we are using with the code snippet below :-

PdfContentEditor contentEditor = new PdfContentEditor();
.../* setting other flags here*/
...
contentEditor.ReplaceText(@"[$]\$" + Data.Name + @"*\$[$]", Data.Value);

The problem we are facing here is that the after replacing , if the value replaced is larger than its allocated space on the PDF, it just overwrites the rest of the content.

In the sample attached, the replaced value of $$F3$$ being a little long, overwrites the "-" and the value of $$F2$$ beside it. I could not find any flag in the API /Forum to do this. Is there a way to pad the oncoming text after replacing a value so that it does not cause any overwriting and everything is displayed properly ?

Thanks

TIF to PDF: File size is huge, how to shrink?

$
0
0
Hello,

We are converting TIFs to PDFs in an application we are developing.  
The PDF file sizes are huge.   For a 268KB TIF,  aspose.pdf outputs over 10 MB pdf file.
In comparison,  OmniPage outputs a 44 KB pdf file,  and Acrobat outputs a 200 KB pdf file.
quality is similar in all 3.

Im using the code from the docs as  http://www.aspose.com/docs/display/pdfnet/Convert+an+Image+to+PDF)

is there anyway to shrink that file size considerably?   I didnt see anything in the API that jumped out at me to do this.

thanks

How we can relate the coordinates of word document to aspose converted image

$
0
0

We are using aspose.pdf (v8.1.0.0)


We have a curly braces on the word document/ pdf document.


This document needs to be converted to image and an overlay needs to be provided on the image.

This overlay will be over the curly braces.


We are not getting the exact coordinates to provide a overlay on the curly braces on the image created by aspose.


Please let us know on how we can relate the coordinates of word document to aspose converted image.


Thanks

Arabic text extraction from PDF

$
0
0
Hi , We are using aspose to extract arabic text from pdf files .
The problem is the extracted text looks encrypted , our code :
public String getString() throws Exception {
com.aspose.pdf.Document pdfDocument =null;
String extractedText = "";
try {
if (inputStream == null) {
pdfDocument = new com.aspose.pdf.Document(this.path);
}
else {
pdfDocument = new com.aspose.pdf.Document(this.inputStream);
}
com.aspose.pdf.TextAbsorber textAbsorber = new com.aspose.pdf.TextAbsorber();
pdfDocument.getPages().accept(textAbsorber);
extractedText = textAbsorber.getText();
}
finally {
pdfDocument.freeMemory();
pdfDocument.dispose();
pdfDocument.close();
pdfDocument=null;
}

return extractedText;
}
Attached the Result of text extraction with sample pdf file.
Could you please assist us to solve this issue .
Thanks in advance.

ImageScale causing Pdf generation to take hang

$
0
0
Setting the ImageScale property causes my Pdf not to generate, it gets stuck loading forever. I've tried setting the ImageScale to different values but it is the same result. Anybody had this/know how to fix it?

Here is the code snippet I've been having problems with:

                if (File.Exists(IMAGE_PATH + Db.getColumn<string>(dataRow, "path"))) {
                    partImage = new Image();
                    partImage.File = IMAGE_PATH +
                        Db.getColumn<string>(dataRow, "path");  //File type is png
                    partImage.FixWidth = 40;
                    partImage.ImageScale = 0.5f;
                    row.Cells.Add().Paragraphs.Add(partImage);
                }

It loads without ImageScale, but the height is extremely stretched which is why I was trying to use ImageScale.

Image in original dimensions: http://puu.sh/hl3zr/489909eb31.jpg

Image generated in Pdf originally: http://puu.sh/hl3AW/47b444f5fb.jpg

All pages are null when instantiating new Document

$
0
0
I am saving an Aspose.Words document as a PDF bytes and later, reading the PDF's bytes into a MemoryStream so a new Aspose Document() object can be instantiated. However, when I instantiate the Document using the constructor that accepts a Stream, it instantiates the Document with three pages in the Document.Pages property, but all three pages are null.

//get bytes from file/ database location

using(var stream = new MemoryStream(bytes))
 var document = new Document(stream, false); 
 }


How do we get the pages to not be null?

Textbox with Justify not working when text contains a parameter

$
0
0
Hi

Is it by design or a bug that text justify works fine unless I put a parameter or other expression into the text?

Thanks,
Greg

What is llx, lly , yrx and ury

$
0
0
What is llx, lly , yrx and ury in rectangle coordinates. When i passed llx as x-axis value, lly as y-axis, urx as width, ury as height. For example am passing 887, 515, 106, 446 in a pdf but it is cropping some other zone.

Please confirm about this 


XFA to Standard PDF form field length

$
0
0
Hello,

I have an Adobe LiveCycle form that I am using Aspose.Pdf to convert to a standard PDF form. This results in field names such as "topmostsubform[0].page[0].fieldname[0]". Unfortunately, the next step in my process is to pass the converted document to another 3rd party module, and it has a limit of 32 characters on form field names, which the converted field names sometimes exceed. From what I can tell, the other module looks at the Field.FullName property, which is of course readonly. I'm looking for a way to either shorten all the field names during conversion (I don't need the form or page) or to change the Field.FullName after the fact. 

The closest I have come was using the FormEditor.RenameField function, but that only changes the part of the FullName after "topmostsubform[0].page[0].", which is usually not enough to accommodate the length constraint.

Any help would be appreciated.

Z

PDF-Android: reading and identifying form fields

$
0
0
I get the form fields using the following code:

String fPath = "whatever...pdf";

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(fPath);

PageCollection pages = pdfDocument.getPages();

for (int i = 1; i <= pages.size(); i++){

Page page = pages.get_Item(i);

com.aspose.pdf.Form form = document.getForm();

com.aspose.pdf.Field[] fields = form.getFieldsInRect(page.getRect());

if(null != fields){

for(Field fld : fields){   

// get field info here

}

}

}

My questions:

1. How do I know if a field is TextField, or a CheckBox, or a Button, etc?

2. When I read coordinates of a field like: 

double x_ = fld.getRect().getLLX();

double y_ = fld.getRect().getLLY();

it gives me values if the fields were "vertically flipped". E.g. if field A is located near to top (say: x=10, y = 10), the above code would give me coordinates close to the bottom. If the page height was 500 then I would get x_ = 10, y_ = 490. How should I interpret it?


Diagonal text watermark that appears only when printing?

$
0
0
Is it possible to have a text watermark/ annotation that only appears when printing, that goes diagonally across the page from bottom left to top right?

It seems like we would want to use the FreeTextAnnotation for this, since that supports the NoView and Print annotation flags. However, I don't see a way to make this text diagonal.

Alternatively, it appears a TextStamp would allow us to set an angle for the text, but has no support for making the text only appear when printing.

An example of how we are trying to format the text is attached.
Viewing all 3131 articles
Browse latest View live