Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > How to insert a picture into the template?

Forum

Search UsersRules
How to insert a picture into the template?
#1
Active user
Points:: 0
Joined:: Jan 11, 2013

Hi, want to load picture or logo from file into template headers but can't find how to. The intension is to be able for customers to choose what logo they want to use for printouts and reports, whitout using PictureLib. Regards
Keijo

Profile
#2
Interested
Points:: 0
Joined:: Apr 5, 2012

If it is logo pic of company.
1. Create Constant (type - ValueStorage).
2. Fr om some wh ere set to this constant picture in valuestorage:

Code
SelectedPic = New Picture(<FileName>, <Transparent>);
Constant  = New ValueStorage(SelectedPic, New Deflation);

3. In spreadsheet docum. create a field picture.
4. In code for showing:
Code
SpArea = Template.GetArea("BaşYazısı");
   
// logo 
SpArea.Drawings.Logo.Picture = Constants.Constant.Get();

Profile
#3
Guest
Points::
Joined::

You can also insert pictures dynamically, but predefined items are the better way.

Code
   Picture = Area.Drawings.Add(SpreadsheetDocumentDrawingType.Picture);
   Picture.Top = 0;
   Picture.Height = 9;
   Picture.Width = 9;
   Picture.Left = 30;
   Picture.Picture = New Picture(FileName);
   Picture.PictureSize = PictureSize.Proportionally;

Profile
#4
Active user
Points:: 0
Joined:: Sep 2, 2013

Hello;

I have binary data stored in ValueStorage field.

Can you tell me please how can I get that data and display as picture in the Product Form?

I'm doing it like:

Code
   ThisObject = Object.Ref.GetObject();
   ThisForm.UnlockFormDataForEdit();

 either this
Code
   ThisForm.Items.PhotoPlaceholder = New Picture(ThisObject.Zdjecie.Get());

 or that
Code
   Items.PhotoPlaceholder.Picture = New Picture(ThisObject.Zdjecie.Get());

 but either there's "wrong type of data" or "item is not open for write". I'm clueless.

Profile
#5
Guest
Points::
Joined::

Hello, Joanna!
The picture form item is a string with an URL, so you need to put your picture to the temp storage and specify an address of it as the form item value.

Profile
#6
Active user
Points:: 0
Joined:: Sep 2, 2013

Thank you! I'll try to do it and get back with the result :)

Profile
#7
Active user
Points:: 0
Joined:: Sep 2, 2013

I'm clueless.

The farthest I could get is to display blank picture.

I know that ValueStorage contains appropriate data since my buttons "save file" and "view file" work properly.

When I tried this:

Code
ObjectValue = FormDataToValue(Object, Type("CatalogObject.CatalogProducts"));
Path = PutToTempStorage(ObjectValue.Zdjecie.Get());
ThisForm.Items.PhotoPlaceholder.Picture = New Picture(Path);


I got:
Code
Catalogue path doesn't exist "e1cib\tempstorage\f22b2601-1839-4ba2-8fc8-c06173efeee5"


Also in This code:

       
Code
ThisObject = Object.Ref.GetObject();
   SelectedPic = New Picture(ThisObject.Zdjecie.Get());
   
   ObjectValue = FormDataToValue(Object, Type("CatalogObject.CatalogProducts"));
        Path = PutToTempStorage(ObjectValue.Zdjecie.Get());

   ImageExt = Items.Add("ImageNew", Type("FormDecoration"), Items.Group8); 
   ImageExt.Type = FormDecorationType.Picture;


Both This:
Code
ImageExt = SelectedPic;   


And This:
Code
ImageExt = Path;


Gives me blank picture.

And This:
Code
ImageExt = New Picture(Path);


Returns "Catalog not found error".



I'm so tired and frustrated... I'm using 1C 8.2.14.528

Profile
#8
Active user
Points:: 0
Joined:: Sep 26, 2012

I cant test on your version of 1C, I use 8.2.17.169
For me work next:

I add attribute "Zdjecie" with type "ValueStorage"
Then add on form item element Field "PictureElement" with type "Image field" and attribute "PictureAddress" with type String (which contain url to picture)

[img]pic_99984[/img]

And connect Data path of Field to attribute

Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
   // Here I initialize attribute of form
   PictureAddress = GetURL(Object.Ref, "Zdjecie");
EndProcedure

Profile
#9
Active user
Points:: 0
Joined:: Sep 2, 2013

Thank you very much ivan avdonin, it works! :D

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.