When i saved a native Dynamics AX 2009 report as pdf or pdf-embed it doesn't show the images in the report i.e. company logo in header section, properly. The image comes very distorted, grayish and repeated.
On the other if i export the image in HTML format the image comes properly.
Had anyone experience a similar issue.
Please note that im saving the report as pdf using "file" option that comes when the report print dialog opens.
Any help would be highly appreciated.
Issue will go if the image format used is one of the following
1. 24bit Bitmap
2. TIFF
I have found a solution for this issue in AX 2009:
Bitmap getImageBitmap(ItemId _itemId)
{
HPLInventImages inventImages; // Column HPLInventImages.ItemImage is EDT:BlobData (which is a container)
Image image;
;
if (!_itemId) return inventImages.ItemImage; // Return null bitmap. The whole AX client crashes if you try to do the resizing code below on a null bitmap.
select firstonly inventImages where inventImages.ItemId==_itemId;
//return inventImages.ItemImage; // Would normally just do this, but see comments below.
// Ok, this next bit is weird!
// There is a known issue with AX reports with images in, getting saved as PDFs:
// In some cases, the images appear as garbage on the PDF.
// I have found that resizing the image before rendering it, causes the image to come out ok on the PDF.
// So the code below does a token resize (by 1.0 times!) operation on the image before returning it.
// That is enough to make the image on the PDF turn out ok.
image=new Image(inventImages.ItemImage);
image.resize(image.width()*1.0,image.height()*1.0,InterpolationMode::InterpolationModeHighQuality);
return image.getData();
}
Related
I can't seem to find any information on this, but does anyone know if it is possible to use an embedded image from my.resources within an ObjectListView SubItem?
I am currently using images stored in an ImageList control, but I find for some reason, those images get corrupted and start displaying imperfections. I don't have the problem if I pull them from the embedded resources as I previously have with the normal listview control.
I am using the ImageGetter routine to return a key reference the ImageList, however, ultimately I would like to pull these from embedded resources. I would like to also do this for animated GIF references as well.
If anyone knows a way, could you please assist. Sample code would be appreciated.
Thanks
You can return three different types from the ImageGetter
int - the int value will be used as an index into the image list
String - the string value will be used as a key into the image list
Image - the Image will be drawn directly (only in OwnerDrawn mode)
So option number 3 could be what you want. Note that you have to set objectListView1.OwnerDraw = true.
If that does not work, an alternative could be to load the images into the ImageList at runtime. There is an example here.
this.mainColumn.ImageGetter = delegate(object row) {
String key = this.GetImageKey(row);
if (!this.listView.LargeImageList.Images.ContainsKey(key)) {
Image smallImage = this.GetSmallImageFromStorage(key);
Image largeImage = this.GetLargeImageFromStorage(key);
this.listView.SmallImageList.Images.Add(key, smallImage);
this.listView.LargeImageList.Images.Add(key, largeImage);
}
return key;
};
This dynamically fetches the images if they haven’t been already fetched. You will need to write the GetImageKey(), GetSmallImageFromStorage() and GetLargeImageFromStorage() methods. Their names will probably be different, depending on exactly how you are deciding which image is shown against which model object.
I'm using Docx4J to make an invoice model.
In the left-side of the page, it's usual to show a legal sentence as: Registered company in ... Book ... Page ...
I have inserted this in my template with a Word text frame.
Well, my issue is: when exporting to .docx, this legal text is shown perfect, but when exporting to .pdf, it's shown as an horizontal table under the other data.
The code to export to PDF is:
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setFoDumpFile(foDumpFile);
foSettings.setWmlPackage(template);
fos = new FileOutputStream(new File("/C:/mypath/prueba_OUT.pdf"));
Docx4J.toFO(foSettings, fos, Docx4J.FLAG_EXPORT_PREFER_XSL);
Any help would be very appreciated.
Thanks.
You'd need to extend the PDF via FO code; see further How to correctly position a header image with docx4j?
Float left may or may not be easy; similarly the rotated text.
In general, the way to work on this is to take the FO generated by docx4j, then hand edit it to something which FOP can convert to a PDF you are happy with. If you can do that, then its a matter of modifying docx4j to generate that FO.
I am trying to convert this Word document with a header showing an image on the right
http://www.filesnack.com/files/cduiejc7
to PDF using this sample code:
https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ConvertOutPDF.java
Here's the result:
http://www.filesnack.com/files/ctjs659h
While the Word document has the header image on the right, the converted PDF shows it on the left.
How can I make docx4j to reproduce the original document as PDF?
Your image is positioned relative to a paragraph:
<w:drawing>
<wp:anchor distT="0" distB="0" distL="114300" distR="114300" simplePos="0" relativeHeight="251658240" behindDoc="0" locked="0" layoutInCell="1" allowOverlap="1" wp14:anchorId="791936E3" wp14:editId="575B92C8">
<wp:simplePos x="0" y="0"/>
<wp:positionH relativeFrom="column">
<wp:posOffset>5317388</wp:posOffset>
</wp:positionH>
<wp:positionV relativeFrom="paragraph">
<wp:posOffset>-325755</wp:posOffset>
</wp:positionV>
docx4j potential to support stuff like that in PDF output is limited by what XSL FO supports. See docx4j's TextBoxTest class for what we can do with text boxes.
Currently, although we can position some textBoxes; we don't do the same for floating images: https://github.com/plutext/docx4j/issues/127
In the meantime, a possible workaround for some cases (eg float right) is to use a table.
Or possibly, you could try putting the image inside a text box!
I run a web-based timeline maker and one of the most requested features is to allow users to print their timeline across multiple sheets of paper instead of squeezing it onto a single sheet.
For example, right now when a user exports his or her timeline to a PDF, it gets compressed onto a single page with landscape orientation so it can be easily printed:
I've been experimenting with the options in PDFKit (which uses wkhtmltopdf behind the scenes) to adjust the page size in the hope that it would allow me to print it across multiple sheets of paper. I was able to generate the same timeline on a single 36" wide page:
What I can't figure out -- and I'm not sure if I need to adjust wkhtmltopdf's properties or my printer's -- is how to print this 36"-wide PDF page across multiple sheets of paper. No matter what settings I adjust, the printer always tries to print it on a single piece of paper:
The code I use to generate the 36"-wide PDF, in case it's important, is:
kit = PDFKit.new(html,
:margin_top => 5,
:margin_right => 0,
:margin_bottom => 20,
:margin_left => 0,
:orientation => 'landscape',
:encoding => "UTF-8",
:page_width => '7in',
:page_height => '36in',
)
You can download the PDF here.
I'm open to ideas. Any feedback would be greatly appreciated. Thank you!
One of the Silverlight 4 features listed in a lot of the PDC documents is Print Preview.
I've searched for examples on how to use this and found nothing so far. Has anyone got this working yet? Can you give me some pointers on how to implement a simple web app with print preview in.
I have not seen print preview as any of them but actual Printing support in which you can control which controls are printed and events based on the printing process.
After looking for a while I found a way to do this by combining some features I found in other projects, but they used it for image manipulation. I tried with printing and it seems to work fine.
Here how it works:
Get the base container for the print contents converted to a bitmap by using WriteableBitmap, here I´ll use a Canvas:
WriteableBitmap wb = new WriteableBitmap(this.canvas1, null);
Use this bitmap as a source for a Image control (can be inside a ScrollViewer, what is even better).
this.imagePreview.Height = wb.PixelHeight;
this.imagePreview.Width = wb.PixelWidth;
this.imagePreview.Source = wb;
Set scaling base units (used 1 percent in this case):
Point scale = new Point();
scale.X = imagePreview.Width/100d;
scale.Y = imagePreview.Height/100d;
Then adjust the scaling using a Slider (optional)
private void vSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
imagePreview.Height = scale.Y * vSlider.Value;
imagePreview.Width = scale.X * vSlider.Value;
}
I think from the lack of responses and the fact that as Hurricanepkt pointed out in his reply Tim Heuer and others talk about a virtual print which if displying the same thing on the screen could be built quite easily into your own bespoke Print Preview functionality that the Print Preview listed in some lists is actually people misinterpretting what the Virtual Print documents actually are.